#ifndef __MY_IPC_H__
#define __MY_IPC_H__

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <stdlib.h>

int sem_p(int semid, int num);
int init_sem(int semid, int num, int val);
int sem_v(int semid, int num);

union semun {
	int val;			   /* Value for SETVAL */
	struct semid_ds *buf;  /* Buffer for IPC_STAT, IPC_SET */
	unsigned short *array; /* Array for GETALL, SETALL */
	struct seminfo *__buf; /* Buffer for IPC_INFO
								(Linux-specific) */
};

struct ipc_info
{
	/*
 *共享内存通信 键值、ID 结构体
 **/
	key_t skey;
	int semid;
	int shmid;

	/*
 *消息队列
 **/
	key_t mkey;
	int msgid;

	/*
 *高级设置消息队列
 **/
	key_t a_key;
	int a_msgid;
};

#endif
